// 获取重置按钮元素
var resetButton = document.getElementById('resetButton');

// 监听按钮的点击事件
resetButton.addEventListener('click', function () {
    clearAndSetMargin(); // 调用清空和设置样式的函数
});

function clearAndSetMargin() {
    var promptElements = document.querySelectorAll('.prompt');
    for (var i = 0; i < promptElements.length; i++) {
        promptElements[i].style.marginTop = '17px';
        promptElements[i].innerHTML = ""
    }
}

function Inspection(paramValue) {
    var text=""
    paramValue=paramValue.toString()
    // document.write(paramValue)

    var flag = [0, 0, 0, 0, 0, 0, 0];


    for (var i = 0; i < paramValue.length; i++) {
        var num = parseInt(paramValue.charAt(i));
        if (!isNaN(num)) {
            flag[i]=num;
        }
    }
    // //检查必填项有没有填
    if (flag[0]==1||flag[0]==0) {
        if (flag[0]==1) {
            text += "物料编号前四位需为2024"
            document.getElementsByTagName('p')[0].innerHTML = "物料编号前四位需为2024"
        } else if(flag[0]==0) {
            document.getElementsByTagName('p')[0].innerHTML = ""
        }
    } else if(flag[0]==2) {
        text += "物料编号应为8位\n"
        document.getElementsByTagName('p')[0].innerHTML = "物料编号应为9位"
    }

    if (flag[1] == 1) {
        text += "物料名称不能为空\n"
        document.getElementsByTagName('p')[1].innerHTML = "物料名称不能为空"
    } else {
        document.getElementsByTagName('p')[1].innerHTML = ""
    }
    if (flag[2] == 1) {
        text += "材料类型不能为空\n"
        document.getElementsByTagName('p')[2].innerHTML = "材料类型不能为空"
    } else if(flag[2]==0) {
        document.getElementsByTagName('p')[2].innerHTML = ""
    }
    if (flag[3] == 1) {
        text += "供应商名称不能为空\n"
        document.getElementsByTagName('p')[3].innerHTML = "供应商名称不能为空"
    } else if(flag[3] == 0) {
        document.getElementsByTagName('p')[3].innerHTML = ""
    }
    if (flag[4] == 1) {
        text += "物料说明不能为空\n"
        document.getElementsByTagName('p')[6].innerHTML = "物料说明不能为空"
    } else if(flag[4]==0){
        document.getElementsByTagName('p')[6].innerHTML = ""
    }

    if (flag[5] == 1) {
        text += "联系人不能为空\n"
        document.getElementsByTagName('p')[7].innerHTML = "联系人不能为空"
    } else if(flag[5]==0){
        document.getElementsByTagName('p')[7].innerHTML = ""
    }
    if (flag[6] == 1) {
        text += "手机号应为11位\n"
        document.getElementsByTagName('p')[8].innerHTML = "手机号应为11位"
    } else if(flag[6]==0) {
        document.getElementsByTagName('p')[8].innerHTML = ""
    }

    var promptElements = document.querySelectorAll('.prompt');
    for (var i = 0; i < promptElements.length; i++) {
        if (promptElements[i].innerHTML.trim() !== '') {
            promptElements[i].style.marginTop = '0px';
        } else {
            promptElements[i].style.marginTop = '17px';
        }
    }
}